﻿using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using ui_test.ViewModels;

namespace ui.test.Views;

public partial class KeyUserControl : UserControl
{
    public IBrush? Backup { get; set; }

    public KeyUserControl()
    {
        DataContext = new KeyUserControlViewModel();
        InitializeComponent();
    }

    public IBrush BackgroundColor
    {
        get => (DataContext as KeyUserControlViewModel).Background;
        set => (DataContext as KeyUserControlViewModel).Background = value;
    }

    public IBrush ForegroundColor
    {
        get => (DataContext as KeyUserControlViewModel).Foreground;
        set => (DataContext as KeyUserControlViewModel).Foreground = value;
    }

    public int CountText
    {
        get => (DataContext as KeyUserControlViewModel).TotalNum;
        set => (DataContext as KeyUserControlViewModel).TotalNum = value;
    }

    public string KeyText
    {
        get
        {
            Console.WriteLine("get ...  ");
            return
                (DataContext as KeyUserControlViewModel).KeyContent;
        }

        set
        {
            Console.WriteLine($"value is {value}");
            (DataContext as KeyUserControlViewModel).KeyContent = value;
        }
    }

    public int Width
    {
        get
        {
            Console.WriteLine("get ...  ");
            return
                (DataContext as KeyUserControlViewModel).Width;
        }

        set
        {
            Console.WriteLine($"value is {value}");
            (DataContext as KeyUserControlViewModel).Width = value;
        }
    }
}